package com.qdxwx.models.manager;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 用户对象 qdx_managers
 * 
 * @author qdxwx
 */
public class Manager implements Serializable {
    private static final long serialVersionUID = 9129936468205103334L;

    /**
     * 关联ID
     */
    private int managerId;

    /**
     * 关联userId
     */
    private long userId;

    /**
     * 用户名称
     */
    private String managerName;

    /**
     * 机构ID
     */
    private Integer companyId;
    /**
     * 角色ID
     */
    private Integer roleId;
    /**
     * 登录名称
     */
    private String loginName;

    /**
     * 手机号码
     */
    private String mobile;
    /**
     * 密码
     */
    private String loginPwd;

    /**
     * 用户性别1=男,2=女,0=未知
     */
    private Integer sex;

    /**
     * 用户头像
     */
    private String avatar;



    /**
     * 备注
     */
    private String remark;

    /**
     * 帐号状态（0正常 1停用）
     */
    private Integer isDisabled;

    /**
     * 最后登陆IP
     */
    private String lastLoginIp;

    /**
     * 最后登陆时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastLoginTime;

    /**
     * 更新者
     */
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 创建者
     */
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;


    //扩展
    private List<Role> roles;
    /**
     * 角色组
     */
    private Integer[] roleIds;
    /**
     * 岗位组
     */
    private Integer[] postIds;


    public Manager() { }

    public boolean isAdmin() {
        return isAdmin(this.managerId);
    }

    public static boolean isAdmin(Integer managerId) {
        return managerId != null && 1 == managerId;
    }

    public int getManagerId() {
        return managerId;
    }

    public void setManagerId(int managerId) {
        this.managerId = managerId;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getManagerName() {
        return managerName;
    }

    public void setManagerName(String managerName) {
        this.managerName = managerName;
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getLoginPwd() {
        return loginPwd;
    }

    public void setLoginPwd(String loginPwd) {
        this.loginPwd = loginPwd;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getIsDisabled() {
        return isDisabled;
    }

    public void setIsDisabled(Integer isDisabled) {
        this.isDisabled = isDisabled;
    }

    public String getLastLoginIp() {
        return lastLoginIp;
    }

    public void setLastLoginIp(String lastLoginIp) {
        this.lastLoginIp = lastLoginIp;
    }

    public LocalDateTime getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(LocalDateTime lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public Integer[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(Integer[] roleIds) {
        this.roleIds = roleIds;
    }

    public Integer[] getPostIds() {
        return postIds;
    }

    public void setPostIds(Integer[] postIds) {
        this.postIds = postIds;
    }

    @Override
    public String toString() {
        return "Manager{" +
                "managerId=" + managerId +
                ", userId='" + userId + '\'' +
                ", managerName='" + managerName + '\'' +
                ", companyId=" + companyId +
                ", roleId=" + roleId +
                ", loginName='" + loginName + '\'' +
                ", mobile='" + mobile + '\'' +
                ", loginPwd='" + loginPwd + '\'' +
                ", sex=" + sex +
                ", avatar='" + avatar + '\'' +
                ", remark='" + remark + '\'' +
                ", isDisabled=" + isDisabled +
                ", lastLoginIp='" + lastLoginIp + '\'' +
                ", lastLoginTime=" + lastLoginTime +
                ", updateBy='" + updateBy + '\'' +
                ", updateTime=" + updateTime +
                ", createBy='" + createBy + '\'' +
                ", createTime=" + createTime +
                ", roles=" + roles +
                ", roleIds=" + Arrays.toString(roleIds) +
                ", postIds=" + Arrays.toString(postIds) +
                '}';
    }
}
